package com.wgworkshop.pems.entity;

import com.wgworkshop.pems.model.AttendanceCountByClassRecord;
import com.wgworkshop.pems.model.AttendanceStudentViewRecord;

import javax.persistence.*;
import java.util.Date;

/**
 * 考勤实体类。
 * Created by wlc on 2017/7/9.
 */
@Entity(name = "attendance")
@SqlResultSetMappings(
        {
                @SqlResultSetMapping(
                        name = "AttendanceStudentViewRecordMapping",
                        classes = {
                                @ConstructorResult(
                                        targetClass = AttendanceStudentViewRecord.class,
                                        columns = {
                                                @ColumnResult(name = "id", type = Long.class),
                                                @ColumnResult(name = "code", type = String.class),
                                                @ColumnResult(name = "name", type = String.class),
                                                @ColumnResult(name = "count", type = Long.class)
                                        }
                                )
                        }
                ),
                @SqlResultSetMapping(
                        name = "AttendanceCountByClassRecordMapping",
                        classes = {
                                @ConstructorResult(
                                        targetClass = AttendanceCountByClassRecord.class,
                                        columns = {
                                                @ColumnResult(name = "course_date", type = Date.class),
                                                @ColumnResult(name = "count", type = Long.class)
                                        }
                                )
                        }
                ),
                @SqlResultSetMapping(
                        name = "AttendanceDetailByClassRecordMapping",
                        entities = {
                                @EntityResult(
                                        entityClass = StudentEntity.class
                                )
                        },
                        columns = {
                                @ColumnResult(name = "course_date", type = Date.class)
                        }
                )
        }
)
public class AttendanceEntity extends AbstractBaseEntity {
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn
    private StudentEntity student;
    @Temporal(TemporalType.DATE)
    private Date courseDate;
    @Temporal(TemporalType.DATE)
    private Date operateDate;

    public StudentEntity getStudent() {
        return student;
    }

    public void setStudent(StudentEntity student) {
        this.student = student;
    }

    public Date getCourseDate() {
        return courseDate;
    }

    public void setCourseDate(Date courseDate) {
        this.courseDate = courseDate;
    }

    public Date getOperateDate() {
        return operateDate;
    }

    public void setOperateDate(Date operateDate) {
        this.operateDate = operateDate;
    }
}
